package com.ruoyi.web.controller.tenant;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TenantPost;
import com.ruoyi.system.service.impl.TenantPostServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * 岗位信息操作处理
 *
 * @author ruoyi
 */
@RestController
@RequestMapping("/tenant/post")
public class TenantPostController extends BaseController {
    @Autowired
    private TenantPostServiceImpl tenantPostService;

    /**
     * 查询租客信息列表
     */
    @PostMapping("/list")
    public TableDataInfo list(@RequestBody TenantPost post) {
        List<TenantPost> tenantPosts = tenantPostService.selectTenantPostList(post);

        return getDataTable(tenantPosts);
    }
//删除
    @PreAuthorize("@ss.hasPermi('system:tenantpost:remove')")
    @Log(title = "租客管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{tenantIds}")
    public AjaxResult delete(@PathVariable Long[] tenantIds) {

        return toAjax(tenantPostService.deleteTenantPostByIds(tenantIds));
    }

    @PostMapping
    public AjaxResult add(@RequestBody TenantPost tenantPost) {
        int i = tenantPostService.insertTenantPost(tenantPost);
        return toAjax(i);
    }

    //点击修改查询返回
    @GetMapping("/{postId}")
    public AjaxResult getInfo(@PathVariable Long postId) {
//        int i = tenantPostService.updateTenantPost(tenantPost);


        return success(tenantPostService.selecttePostById(postId));

    }

    //修改租客

    @PostMapping("/update")
    public AjaxResult edit(@RequestBody TenantPost tenantPost) {

        return toAjax(tenantPostService.updateTenantPost(tenantPost));
    }





}
